package net.llz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import net.llz.mapper.PermissionMapper;
import net.llz.mapper.RoleMapper;
import net.llz.mapper.UserMapper;
import net.llz.model.RoleDO;
import net.llz.model.UserDO;
import net.llz.service.UserService;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Autowired
    private RoleMapper roleMapper;

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public UserDO findAllUserInfoByUsername(String username) {

        UserDO userDO = userMapper.findByUsername(username);

       // UserDO userDO = userMapper.selectOne(new QueryWrapper<UserDO>().eq("username",username));

        //用户的角色集合
        List<RoleDO> roleList =  roleMapper.findRoleListByUserId(userDO.getId());
        userDO.setRoleList(roleList);

        System.out.println("测试结果"+userDO.getId()+userDO.getUsername());

        return userDO;
    }

    @Override
    public UserDO findSimpleUserInfoById(int userId) {
        return null;
    }

    @Override
    public UserDO findSimpleUserInfoByUsername(String username) {
        return null;
    }
}
